package simplefactory;

import simplefactory.factory.HumanFactory;
import simplefactory.human.BlackHuman;
import simplefactory.human.Human;
import simplefactory.human.WhiteHuman;
import simplefactory.human.YellowHuman;

/**
 * @author heyuduo
 * @date 2022/7/3 15:56
 *
 * 简单工厂模式有两方面
 * 1.工厂 --用作创建对象，通过类型判断
 * 2.接口 --公有接口，比如肤色，语言
 * 缺点：
 *      当想添加更多的方法时，或者想要创建男人女人时，比较繁杂，未实现开闭原则
 */
public class NvWa {
    public static void main(String[] args) {
        HumanFactory factory = new HumanFactory();
        Human blackHuman = factory.createHuman(BlackHuman.class);
        blackHuman.printColor();
        Human whiteHuman = factory.createHuman(WhiteHuman.class);
        whiteHuman.printColor();

    }
}
